Skip to content

[ISSUE #22] Created spoint_deg, scircle_deg, spoly_deg functions. #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2023

Conversation

dura0ok
Copy link

@dura0ok dura0ok commented Jul 31, 2023

@esabol @vitcpp please, review it.

@vitcpp
Copy link
Contributor

vitcpp commented Jul 31, 2023

@stepan-neretin7 In general, I'm ok with your patch except of some cosmetic issues (float -> float8 is important). To create a complete patch I would ask to change the version to 1.3.0 (API is changed) and create a new upgrade script with name pg_sphere--1.2.3--1.3.0.sql.in in upgrade_scripts subdirectory. Makefile should also be updated to add support for the new upgrade script. Upgrade scripts are used to alter the existing schema of previous version to the new schema. In our case we have to create new functions in the new upgrade script. Thank you!

@dura0ok dura0ok force-pushed the deg_functions branch 3 times, most recently from aa46131 to e0c76c4 Compare August 1, 2023 05:30
@dura0ok dura0ok requested a review from esabol August 1, 2023 05:30
@dura0ok dura0ok force-pushed the deg_functions branch 2 times, most recently from 048e068 to 5ccfedb Compare August 1, 2023 05:44
@dura0ok
Copy link
Author

dura0ok commented Aug 1, 2023

@vitcpp I have updated the version

@dura0ok dura0ok requested a review from esabol August 1, 2023 07:26
@dura0ok
Copy link
Author

dura0ok commented Aug 1, 2023

I also added the spoly_deg function, which accepts, as in the pr of 5 years ago, an array of float8, where there are consecutive pairs in the sequence of two float8 per point for the polygon

@esabol
Copy link
Contributor

esabol commented Aug 2, 2023

I also added the spoly_deg function, which accepts, as in the pr of 5 years ago, an array of float8, where there are consecutive pairs in the sequence of two float8 per point for the polygon

Thank you! I was just going to suggest that adding a spoly_deg() for the sake of completeness might be a good idea. 😄

@dura0ok
Copy link
Author

dura0ok commented Aug 2, 2023

I also added the spoly_deg function, which accepts, as in the pr of 5 years ago, an array of float8, where there are consecutive pairs in the sequence of two float8 per point for the polygon

Thank you! I was just going to suggest that adding a spoly_deg() for the sake of completeness might be a good idea. smile

Sorry, I didn't really get your message. So I guessed your thought? :D
And how do you like pr in general, how about approve?

@esabol
Copy link
Contributor

esabol commented Aug 2, 2023

And how do you like pr in general, how about approve?

Sorry, I thought I already did. Approved!

@esabol
Copy link
Contributor

esabol commented Aug 2, 2023

Oh, sorry, I found one more minor thing: I saw you fixed the "radius must be not greater than 90 degrees" error message, but there is another version of that error on line 84 of src/circle.c. Could you fix line 84 similar to how you fixed line 366?

@dura0ok
Copy link
Author

dura0ok commented Aug 2, 2023

Oh, sorry, I found one more minor thing: I saw you fixed the "radius must be not greater than 90 degrees" error message, but there is another version of that error on line 84 of src/circle.c. Could you fix line 84 similar to how you fixed line 366?

Of course, I've already fixed it. However, it is strange that there are no tests specifically for this error in circle.sql.
I can add if necessary and it will be appropriate in this pull request

@vitcpp
Copy link
Contributor

vitcpp commented Aug 2, 2023

@stepan-neretin7 I added some review comments. Most of the comments are minor and related to the code formatting. I would propose to work out these comments. Another performance issue I've found is in spherepoly_deg(). It will work as it is now but it is not an effective solution. Anyway, I'm ok to apply PR without redesign of this function.

src/polygon.c Outdated
for (i = 0; i < num_elements - 1; i += 2)
{
point = DirectFunctionCall2(
spherepoint_from_long_lat_deg, Float8GetDatum(array_data[i]), Float8GetDatum(array_data[i+1])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not an effective solution. spherepoint_from_long_lat_deg returns palloc-ed spoint. Later this spoint is copied into already pallocated points array. I propose to pfree it after line 892. It will work but I would rather think how to avoid unecessary palloc.

@dura0ok dura0ok force-pushed the deg_functions branch 3 times, most recently from 30a17c7 to df45187 Compare August 2, 2023 09:53
@dura0ok dura0ok requested review from esabol and vitcpp August 2, 2023 10:40
@dura0ok
Copy link
Author

dura0ok commented Aug 2, 2023

I corrected all the comments
Look again, please @esabol

@dura0ok dura0ok requested a review from esabol August 2, 2023 18:11
@dura0ok
Copy link
Author

dura0ok commented Aug 3, 2023

Sorry for trivial coding style issues. I fixed it @esabol

@dura0ok dura0ok requested a review from esabol August 3, 2023 05:08
@dura0ok dura0ok requested a review from vitcpp August 3, 2023 10:17
src/polygon.c Outdated
);
}
PG_RETURN_POINTER(spherepoly_from_array(points, np));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unecessary blank line please.

@dura0ok dura0ok force-pushed the deg_functions branch 2 times, most recently from 9d8b007 to 4199d35 Compare August 4, 2023 04:49
@dura0ok dura0ok requested a review from vitcpp August 4, 2023 05:08
@dura0ok dura0ok requested a review from vitcpp August 4, 2023 08:22
@dura0ok dura0ok changed the title [ISSUE #22] Created spoint_deg, scircle_deg functions. [ISSUE #22] Created spoint_deg, scircle_deg, spoly_deg functions. Aug 4, 2023
Copy link
Contributor

@esabol esabol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@vitcpp vitcpp merged commit 7fb5552 into postgrespro:master Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants